<?php 

if(isset($_POST['tablename'])){
	$tablename = $_POST['tablename'];
	require_once $tablename.'.php';
	$u = new $tablename();
}else {
	echo "table name not set";
}
//$u = new users();

if($_POST['operation'] == 'delete'){
	if(isset($_POST['id'])){
		$u->delete($_POST['id']);
		echo "Deleting process executed";
	}else {
		echo "Noting set";
	}
}

if($_POST['operation'] == 'edit'){
$data = array();
foreach ($_POST as $key => $value) {
	if($key != "operation" && $key != "tablename")	
		array_push($data,$value);
}
//print_r("<pre>");print_r($data);print_r("</pre>");

$u->edit($data);
if(isset($_POST)){
	echo "set";
}else {
	echo "not set";
}
}
if($_POST['operation'] == 'add'){
	$data = array();
foreach ($_POST as $key => $value) {
	if($key != "operation" && $key != "tablename")	
		array_push($data,$value);
}
print_r("<pre>");print_r($data);print_r("</pre>");
$u->insert($data);
if(isset($_POST)){
	echo "set";
}else {
	echo "not set";
}
}